/*
 * RtpHeader.h
 *
 *  Created on: Dec 2, 2011
 *      Author: shaohong
 */

#ifndef RTPHEADER_H_
#define RTPHEADER_H_

#include <stdint.h>
#include <string>

using namespace std;

namespace nmps {

enum PayloadType
{ 	//PCMA:8, PCMU:0
	 PCMU = 0x0
	,PCMA = 0x8
};

class RtpHeader {
public:
	RtpHeader();
	virtual ~RtpHeader();

	/**
	 * Get the length (in bytes) of the RTP header
	 */
	int getHeaderLength();


    int getCsrcCount() const;

    /**
     * return the packetized form of the RTP header, ready to be put as UDP payload
     */
    const unsigned char * getPacketizedForm();

    PayloadType getPayloadType() const;
    unsigned int getSeqNum() const;
    uint32_t getSsrc() const;
    uint32_t getTimeStamp() const;
    int getVersion() const;
    bool isHasExtension() const;
    bool isUseMarker() const;
    bool isUsePadding() const;
    void setCsrcCount(int CSRC_Count);
    void setHasExtension(bool hasExtension);
    void setPayloadType(PayloadType payloadType);
    void setSsrc(unsigned long  SSRC);
    void setTimeStamp(unsigned long  timeStamp);
    void setUseMarker(bool useMarker);
    void setUsePadding(bool usePadding);
    void setVersion(int version);

    void incrementSeqNum();	// increase the seq number by 1

    string toString();

private:
	int version;
	bool usePadding;
	bool hasExtension;	//always false in our case
	int CSRC_Count;	// always 0 in our case
	bool useMarker;
	PayloadType payloadType; // PCMA:8, PCMU:0
	uint16_t seqNum ;
	uint32_t timeStamp;
	uint32_t SSRC;

	unsigned char packetizedForm[12]; // without extension, RTP header is 12 bytes in the simplest case

};

} /* namespace nmps */
#endif /* RTPHEADER_H_ */
